﻿Imports System.Text

Public Class ASPXButton

    Private CodeType As String
    Private Name As String
    Private RunAtServer As Boolean

    Public Sub New(ByVal CodeType As String, ByVal Name As String, Optional ByVal RunAtServer As Boolean = True)
        Me.CodeType = CodeType
        Me.Name = Name
        Me.RunAtServer = RunAtServer
    End Sub

    Public Overrides Function ToString() As String
        Dim s As String = ""
        s = "<asp:Button "


        s = s & "id=""cmd" & Name & """"

        If RunAtServer Then
            s = s & " runat=""server"""
        End If

        s = s & " Text=""" & Name & """"

        Select Case CodeType
            Case CodeTypeEnum.CS2005
                s = s & " OnClick=""cmd" & Name & "_Click"""
        End Select

        s = s & " cssClass=""PCGButton"""
        'Select Case ButtonType.ToUpper
        '    Case "IMAGEBUTTON"
        '        s = s & " onmouseover=""Javascript:this.src='" & Name & "A.gif';"" onmouseout=""Javascript:this.src='" & Name & ".gif';"" ImageUrl=""" & Name & ".gif"""
        'End Select

        s = s & ">"
        s = s & "</asp:Button>"

        Return s
    End Function

    Public Function DesignerToString() As String
        Dim sb As New StringBuilder
        sb.AppendLine("    '''<summary>")
        sb.AppendLine("    '''cmd" & Name & " control.")
        sb.AppendLine("    '''</summary>")
        sb.AppendLine("    '''<remarks>")
        sb.AppendLine("    '''Auto-generated field.")
        sb.AppendLine("    '''To modify move field declaration from designer file to code-behind file.")
        sb.AppendLine("    '''</remarks>")
        sb.Append("    Protected WithEvents cmd" & Name & " As ")

        sb.AppendLine("Global.System.Web.UI.WebControls.Button")

        Return sb.ToString
    End Function
End Class
